package com.jx.mlxg;

<<<<<<< HEAD
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jx.mlxg.config.MybatisPlusConfig;
import com.jx.mlxg.entity.ApprovalFlow;
import com.jx.mlxg.entity.ApprovalNode;
import com.jx.mlxg.mapper.ApprovalFlowMapper;
import com.jx.mlxg.mapper.ApprovalNodeMapper;
import com.jx.mlxg.mapper.ApprovalRecordMapper;
import com.jx.mlxg.service.ApprovalFlowService;
import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

import jakarta.annotation.PostConstruct; // 修改为 Jakarta EE 注解
import org.springframework.scheduling.annotation.EnableScheduling;

import java.io.File;

@SpringBootApplication
@MapperScan("com.jx.mlxg.mapper")
@Import({MybatisPlusConfig.class})
@EnableScheduling
=======
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

@SpringBootApplication
@MapperScan
>>>>>>> eb72a42842a7e02f996c4f2d21dc4051aa14ecf1
public class MlxgProjectApplication {

    public static void main(String[] args) {
        SpringApplication.run(MlxgProjectApplication.class, args);
<<<<<<< HEAD
        String keyPath = System.getProperty("user.dir") + File.separator + "play" + File.separator + "apiclient_key.pem";
        System.out.println("私钥路径: " + keyPath);
        System.out.println("文件是否存在: " + new File(keyPath).exists());
    }

//    @Autowired
//    private ApprovalFlowService approvalFlowService;
//    @Autowired
//    private ApprovalFlowMapper approvalFlowMapper;
//    @Autowired
//    private ApprovalNodeMapper approvalNodeMapper;
//    @Autowired
//    private ApprovalRecordMapper approvalRecordMapper;

//    @PostConstruct // 使用 Jakarta EE 注解
//    public void initApprovalFlow() {
//        // 检查是否已存在审批流定义
//        boolean flowExists = approvalFlowService.getOne(new QueryWrapper<ApprovalFlow>()
//                .eq("flow_name", "工厂发货审批")) != null;
//
//        if (!flowExists) {
//            // 创建审批流
//            ApprovalFlow approvalFlow = new ApprovalFlow();
//            approvalFlow.setFlowName("工厂发货审批");
//            approvalFlow.setFlowDescription("工厂发货审批流程");
//            approvalFlowService.save(approvalFlow);
//
//            // 创建第一个节点：工厂管理员审批
//            ApprovalNode node1 = new ApprovalNode();
//            node1.setFlowId(approvalFlow.getFlowId());
//            node1.setNodeName("工厂管理员审批");
//            node1.setNodeRole(2); // 工厂管理员角色
//            node1.setNodeOrder(1);
//            node1.setAutoApproveTime(0); // 不自动通过
//            approvalNodeMapper.insert(node1);
//
//            // 创建第二个节点：董事长审批
//            ApprovalNode node2 = new ApprovalNode();
//            node2.setFlowId(approvalFlow.getFlowId());
//            node2.setNodeName("董事长审批");
//            node2.setNodeRole(1); // 董事长角色
//            node2.setNodeOrder(2);
//            node2.setAutoApproveTime(120); // 2小时自动通过
//            approvalNodeMapper.insert(node2);
//        }
//    }
=======
    }

>>>>>>> eb72a42842a7e02f996c4f2d21dc4051aa14ecf1
}
